package ui;

import java.awt.BorderLayout;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.ScrollPaneConstants;


/**
 * Classe che rappresenta il pannello in cui vengono visualizzati tutti i messaggi scritti dagli altri utenti
 * 
 * @author Java e Le Storie Tese
 *
 */
public class ReadingPanel extends JPanel implements IReadingPanel{

	private static final long serialVersionUID = 0;
	private JTextArea readingArea;
	
	public ReadingPanel() {
		super();
		
		this.setSize(500, HEIGHT);
		generateReadingArea();
		
		this.readingArea.setLineWrap(true);
		JScrollPane jScrollPane = new JScrollPane(readingArea);
		jScrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
		this.add(jScrollPane,BorderLayout.CENTER);
		
		
	}

	public void generateReadingArea() {
		
		this.readingArea=new JTextArea(15,30);
		this.readingArea.setEditable(false);
		this.readingArea.setFocusable(false);
		
	}
	
	public void append(String read){
		
		this.readingArea.append(read+"\n");
		this.readingArea.setCaretPosition(readingArea.getText().length());
		
	}
	
	public JTextArea getReadingArea() {
		return readingArea;
	}


	
}
	

